<?php

define ('ITEM_IMAGE_TRUNK_BASE_DIR', __dir__.'/img');
define ('ITEM_IMAGE_UPLOAD_DIR', ITEM_IMAGE_TRUNK_BASE_DIR.'/upload');
define ('ITEM_IMAGE_UPLOAD_BASE_URL', '/img/upload');

define ('ITEM_IMAGE_BASE_DIR_ORIGINAL', '/img/o/');
define ('ITEM_IMAGE_BASE_DIR_SIZE_SMALL', '/img/s/');
define ('ITEM_IMAGE_BASE_DIR_SIZE_MEDIUM', '/img/m/');
define ('ITEM_IMAGE_BASE_DIR_SIZE_LARGE', '/img/l/');

define ('ITEM_IMAGE_DIR', 'items');
define ('PAGE_REPLY_COUNT', 100);

define ('ITEM_RATE_NO', 1);
define ('ITEM_RATE_YES', 2);

define ('NO_AVAILABLE_IMAGE', __dir__.'/images/no_image_avail.jpg');


define ('SYS_DEFAULT_DATABASE', 'weekdo');
if ($_SERVER['SERVER_ADDR'] == '60.10.1.172') {
	define ('SYS_DB_USER', 'iselect1206');
	define ('SYS_DB_PASSWORD', '5G,E5aFaSvx.:Txu');
} else {
	define ('SYS_DB_USER', 'root');
	define ('SYS_DB_PASSWORD', 'root');
}

date_default_timezone_set('Asia/Shanghai');
session_start();

require_once __DIR__.'/include/class.sys.php';
require_once __DIR__.'/include/class.user.php';
require_once __DIR__.'/include/class.item.php';
require_once __DIR__.'/include/class.troop.php';
require_once __DIR__.'/include/class.page.php';
require_once __DIR__.'/include/class.typelist.php';
require_once __DIR__.'/include/class.bond.php';
require_once __DIR__.'/include/class.resizeimage.php';
require_once __DIR__.'/include/class.itemimage.php';

if ($_POST['login'] && $_POST['passwd'])
{
	user::login($_POST['login'], $_POST['passwd']);
}

if ($_COOKIE['user_logged'] && $_COOKIE['user_id'] && $_COOKIE['user_nickname'] && !$_SESSION['user_id'])
{
	//var_dump($_COOKIE['user_logged']);exit;
	$user_id = $_COOKIE['user_id'];
	$user_nickname = $_COOKIE['user_nickname'];
	$user_info = user::getById($user_id);
	
	if ($user_info['user_nickname'] == $user_nickname)
	{
		if (!user::login($user_info['user_nickname'], $user_info['user_password']))
			user::logout();
	}
}
